import java.util.ArrayList;
import java.util.List;

public class Solution1656 {

    int n;
    int now=0;
    String[] s;

    public Solution1656(int n) {
        this.n=n;
        s=new String[n];
    }

    public List<String> insert(int idKey, String value) {
        s[idKey-1]=value;
        List<String> ans=new ArrayList<>();
        while (now<n && s[now]!=null){
            ans.add(s[now++]);
        }
        return ans;
    }

    public static void main(String[] args) {
        Solution1656 solution1656=new Solution1656(5);
        System.out.println(solution1656.insert(3,"cccc"));
        System.out.println(solution1656.insert(1,"aaaa"));
        System.out.println(solution1656.insert(2,"bbbb"));
        System.out.println(solution1656.insert(5,"eeee"));
        System.out.println(solution1656.insert(4,"dddd"));
    }
}
